package xjtu.se.articlecommunity.common.impl;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import xjtu.se.articlecommunity.common.CacheService;

@Service
@Transactional
@CacheConfig
public class CacheServiceImpl implements CacheService {
    @Override
    @CachePut(value = "verifyCode", key = "#key")
    public String saveVerificationCode(String key, String code) {
        return code;
    }

    @Override
    @Cacheable(value = "verifyCode", key = "#key")
    public String findVerificationCode(String key) {
        return null;
    }

    @Override
    @CacheEvict(value = "verifyCode", key = "#key")
    public void clearVerificationCode(String key) {
        return;
    }

    @Override
    @CachePut(value = "MessSseEmitter", key = "#key")
    public SseEmitter saveMessSseEmitter(String key, SseEmitter sseEmitter) {
        return sseEmitter;
    }

    @Override
    @Cacheable(value = "MessSseEmitter", key = "#key")
    public SseEmitter findMessSseEmitter(String key) {
        return null;
    }

    @Override
    @CacheEvict(value = "MessSseEmitter", key = "#key")
    public void clearMessSseEmitter(String key) {
        return;
    }
}
